transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

test NaN.py (549B)


      1 #!/usr/bin/env python2
      2 
      3 from __future__ import print_function
      4 import sys
      5 import numpy
      6 
      7 from model import *
      8 from relations import *
      9 
     10 if __name__ == '__main__':
     11     if len(sys.argv)<2:
     12         print('Usage: {0} model'.format(sys.argv[0]), file=sys.stderr)
     13         sys.exit(1)
     14     model = Model(None, {'model name': 'test'}, sys.argv[1])
     15     for parameter in model.embeddings.parameters + model.relations.parameters:
     16         if numpy.isnan(parameter.get_value().sum()):
     17             print('NaN found')
     18             sys.exit(0)
     19     print('NaN not found')